package subject.trees;

import java.util.ArrayList;
import java.util.List;

public class flatten {
    public static void main(String[] args) {
//        TreeNode root = new TreeNode(1);
//        List<TreeNode> list = new ArrayList<TreeNode>();
//        preorderTraversal(root, list);
//        int size = list.size();
//        for (int i = 1; i < size; i++) {
//            TreeNode prev = list.get(i - 1), curr = list.get(i);
//            prev.left = null;
//            prev.right = curr;
//        }


    }

    public static void preorderTraversal(TreeNode root, List<TreeNode> list) {
        if (root != null) {
            list.add(root);
            preorderTraversal(root.left, list);
            preorderTraversal(root.right, list);
        }
    }


}
